geom_smooth(method = "gam", show.legend = FALSE) +
geom_jitter(data = datasub, size=1, alpha=.8) +
geom_vline(xintercept = 0)+
theme_bw()+
ylim(0, 420)+
annotate(
geom="text", x = 20, y = 410, size = 3, color = "gray57", fontface=2,
label = "People's Vote \ncampaign email")+
annotate(
geom = "curve", x = 20, y = 390, xend = 0, yend = 310,
curvature = -.2, arrow = arrow(length = unit(2, "mm")), colour="gray57")+
labs(x = "Day relative to treatment",
y = "Daily MP contact \nvia WriteToThem.com",
title="(No) evidence of substitution effects",
color = "")+
theme(legend.position = "bottom")+
guides(color=guide_legend(nrow=1, byrow=TRUE))+
theme(
plot.title = element_text(hjust = 0, color = "gray57", size = 12, face="bold"),
legend.text = element_text(hjust = 0, color = "gray57", size = 10, face="bold"),
axis.title = element_text(hjust = .5, color = "gray57", size = 10, face="bold"))
ggsave("Figure3.png", dpi=600)
coefficients_1week<-lm_robust(outcome_1week ~ treat, data=data1)$coefficients
coefficients_1week<-lm(outcome_1week ~ treat, data=data1)$coefficients
coefficients_1week<-lm(outcome_1week ~ treat, data=data1)$coefficients
coefficients_3days<-lm(outcome ~ treat, data=data2)$coefficients
ses_1week<-(lm(outcome_1week ~ treat, data=data2)$std.error)*100
ses_3days<-(lm(outcome ~ treat, data=data2)$std.error)*100
tab0<-NA
tab0 <- data.frame(c(rep("t+3",1), rep("t+3",1), rep("t+7",1), rep("t+7",1)))
tab0$Time <- NA
tab0$Condition <- NA
tab0$mean <- NA
tab0$Cilower <- NA
tab0$Ciupper <- NA
colnames(tab0) <- c("Time", "Condition", "Mean", "Ci_lower", "Ci_upper")
tab0[1,3]<-coefficients_3days[1]*100
tab0[2,3]<-coefficients_3days[2]*100
tab0[3,3]<-coefficients_1week[1]*100
tab0[4,3]<-coefficients_1week[2]*100
tab0$Ci_upper<- c(coefficients_3days[1]*100 + 1.96*ses_3days[1], coefficients_3days[2]*100 + 1.96*ses_3days[2], coefficients_1week[1]*100 + 1.96*ses_1week[1],
coefficients_1week[2]*100 + 1.96*ses_1week[2])
tab0$Ci_lower<- c(coefficients_3days[1]*100 - 1.96*ses_3days[1], coefficients_3days[2]*100 - 1.96*ses_3days[2], coefficients_1week[1]*100 - 1.96*ses_1week[1],
coefficients_1week[2]*100 - 1.96*ses_1week[2])
tab0[1,2]<-"Control"
tab0[2,2]<-"Email"
tab0[3,2]<-"Control"
tab0[4,2]<-"Email"
?aes
ggplot(tab0, aes(x=Time, y=Mean, colour=Condition)) +
geom_errorbar(aes(ymin=Ci_lower, ymax=Ci_upper), width=.1) +  scale_colour_manual(values=c("grey40", "black", "grey40", "black")) +
geom_line() + geom_point() + geom_hline(yintercept=0, colour="grey", linetype = "dashed", size = 1) +
theme_bw() + ggtitle("% writing to their MP after 3 and 7 days") + coord_cartesian(ylim = c(0, 4)) +  ylab("% writing to their MP") +  xlab("Days after treatment")
ggsave("results_time.png", width = 6, height = 5)
coefficients_1week<-lm(outcome_1week ~ treat, data=data1)$coefficients
coefficients_3days<-lm(outcome ~ treat, data=data1)$coefficients
ses_1week<-(lm(outcome_1week ~ treat, data=data1)$std.error)*100
ses_3days<-(lm(outcome ~ treat, data=data1)$std.error)*100
tab0<-NA
tab0 <- data.frame(c(rep("t+3",1), rep("t+3",1), rep("t+7",1), rep("t+7",1)))
tab0$Time <- NA
tab0$Condition <- NA
tab0$mean <- NA
tab0$Cilower <- NA
tab0$Ciupper <- NA
colnames(tab0) <- c("Time", "Condition", "Mean", "Ci_lower", "Ci_upper")
tab0[1,3]<-coefficients_3days[1]*100
tab0[2,3]<-coefficients_3days[2]*100
tab0[3,3]<-coefficients_1week[1]*100
tab0[4,3]<-coefficients_1week[2]*100
tab0$Ci_upper<- c(coefficients_3days[1]*100 + 1.96*ses_3days[1], coefficients_3days[2]*100 + 1.96*ses_3days[2], coefficients_1week[1]*100 + 1.96*ses_1week[1],
coefficients_1week[2]*100 + 1.96*ses_1week[2])
tab0$Ci_lower<- c(coefficients_3days[1]*100 - 1.96*ses_3days[1], coefficients_3days[2]*100 - 1.96*ses_3days[2], coefficients_1week[1]*100 - 1.96*ses_1week[1],
coefficients_1week[2]*100 - 1.96*ses_1week[2])
tab0[1,2]<-"Control"
tab0[2,2]<-"Email"
tab0[3,2]<-"Control"
tab0[4,2]<-"Email"
ggplot(tab0, aes(x=Time, y=Mean, colour=Condition)) +
geom_errorbar(aes(ymin=Ci_lower, ymax=Ci_upper), width=.1) +  scale_colour_manual(values=c("grey40", "black", "grey40", "black")) +
geom_line() + geom_point() + geom_hline(yintercept=0, colour="grey", linetype = "dashed", size = 1) +
theme_bw() + ggtitle("% writing to their MP after 3 and 7 days") + coord_cartesian(ylim = c(0, 4)) +  ylab("% writing to their MP") +  xlab("Days after treatment")
ggsave("results_time.png", width = 6, height = 5)
coefficients_1week<-lm(outcome_1week ~ treat, data=data1)$coefficients
coefficients_3days<-lm(outcome ~ treat, data=data1)$coefficients
ses_1week<-(lm(outcome_1week ~ treat, data=data1)$std.error)*100
ses_3days<-(lm(outcome ~ treat, data=data1)$std.error)*100
tab0<-NA
tab0 <- data.frame(c(rep("t+3",1), rep("t+3",1), rep("t+7",1), rep("t+7",1)))
tab0$Time <- NA
tab0$Condition <- NA
tab0$mean <- NA
tab0$Cilower <- NA
tab0$Ciupper <- NA
colnames(tab0) <- c("Time", "Condition", "Mean", "Ci_lower", "Ci_upper")
tab0[1,3]<-coefficients_3days[1]*100
tab0[2,3]<-coefficients_3days[2]*100
tab0[3,3]<-coefficients_1week[1]*100
tab0[4,3]<-coefficients_1week[2]*100
tab0$Ci_upper<- c(coefficients_3days[1]*100 + 1.96*ses_3days[1], coefficients_3days[2]*100 + 1.96*ses_3days[2], coefficients_1week[1]*100 + 1.96*ses_1week[1],
coefficients_1week[2]*100 + 1.96*ses_1week[2])
tab0$Ci_lower<- c(coefficients_3days[1]*100 - 1.96*ses_3days[1], coefficients_3days[2]*100 - 1.96*ses_3days[2], coefficients_1week[1]*100 - 1.96*ses_1week[1],
coefficients_1week[2]*100 - 1.96*ses_1week[2])
tab0[1,2]<-"Control"
tab0[2,2]<-"Email"
tab0[3,2]<-"Control"
tab0[4,2]<-"Email"
ggplot(tab0, aes(x=Time, y=Mean, colour=Condition)) +
geom_errorbar(aes(ymin=Ci_lower, ymax=Ci_upper), width=.1) +  scale_colour_manual(values=c("grey40", "black", "grey40", "black")) +
geom_line() + geom_point() + geom_hline(yintercept=0, colour="grey", linetype = "dashed", size = 1) +
theme_bw() + ggtitle("% writing to their MP after 3 and 7 days") + coord_cartesian(ylim = c(0, 4)) +  ylab("% writing to their MP") +  xlab("Days after treatment")
library(estimatr)
coefficients_1week<-lm(outcome_1week ~ treat, data=data1)$coefficients
coefficients_3days<-lm(outcome ~ treat, data=data1)$coefficients
ses_1week<-(lm(outcome_1week ~ treat, data=data1)$std.error)*100
ses_3days<-(lm(outcome ~ treat, data=data1)$std.error)*100
tab0<-NA
tab0 <- data.frame(c(rep("t+3",1), rep("t+3",1), rep("t+7",1), rep("t+7",1)))
tab0$Time <- NA
tab0$Condition <- NA
tab0$mean <- NA
tab0$Cilower <- NA
tab0$Ciupper <- NA
colnames(tab0) <- c("Time", "Condition", "Mean", "Ci_lower", "Ci_upper")
tab0[1,3]<-coefficients_3days[1]*100
tab0[2,3]<-coefficients_3days[2]*100
tab0[3,3]<-coefficients_1week[1]*100
tab0[4,3]<-coefficients_1week[2]*100
tab0$Ci_upper<- c(coefficients_3days[1]*100 + 1.96*ses_3days[1], coefficients_3days[2]*100 + 1.96*ses_3days[2], coefficients_1week[1]*100 + 1.96*ses_1week[1],
coefficients_1week[2]*100 + 1.96*ses_1week[2])
tab0$Ci_lower<- c(coefficients_3days[1]*100 - 1.96*ses_3days[1], coefficients_3days[2]*100 - 1.96*ses_3days[2], coefficients_1week[1]*100 - 1.96*ses_1week[1],
coefficients_1week[2]*100 - 1.96*ses_1week[2])
tab0[1,2]<-"Control"
tab0[2,2]<-"Email"
tab0[3,2]<-"Control"
tab0[4,2]<-"Email"
ggplot(tab0, aes(x=Time, y=Mean, colour=Condition)) +
geom_errorbar(aes(ymin=Ci_lower, ymax=Ci_upper), width=.1) +  scale_colour_manual(values=c("grey40", "black", "grey40", "black")) +
geom_line() + geom_point() + geom_hline(yintercept=0, colour="grey", linetype = "dashed", size = 1) +
theme_bw() + ggtitle("% writing to their MP after 3 and 7 days") + coord_cartesian(ylim = c(0, 4)) +  ylab("% writing to their MP") +  xlab("Days after treatment")
ggsave("results_time.png", width = 6, height = 5)
ggplot(tab0, aes(x=Time, y=Mean, colour=Condition))
ggplot(tab0, aes(x=Time, y=Mean, colour=Condition)) +
geom_errorbar(aes(ymin=Ci_lower, ymax=Ci_upper), width=.1) +  scale_colour_manual(values=c("grey40", "black", "grey40", "black"))
coefficients_1week<-lm(outcome_1week ~ treatdum, data=data1)$coefficients
coefficients_3days<-lm(outcome ~ treatdum, data=data1)$coefficients
ses_1week<-(lm(outcome_1week ~ treatdum, data=data1)$std.error)*100
ses_3days<-(lm(outcome ~ treatdum, data=data1)$std.error)*100
tab0<-NA
tab0 <- data.frame(c(rep("t+3",1), rep("t+3",1), rep("t+7",1), rep("t+7",1)))
tab0$Time <- NA
tab0$Condition <- NA
tab0$mean <- NA
tab0$Cilower <- NA
tab0$Ciupper <- NA
colnames(tab0) <- c("Time", "Condition", "Mean", "Ci_lower", "Ci_upper")
tab0[1,3]<-coefficients_3days[1]*100
tab0[2,3]<-coefficients_3days[2]*100
tab0[3,3]<-coefficients_1week[1]*100
tab0[4,3]<-coefficients_1week[2]*100
tab0$Ci_upper<- c(coefficients_3days[1]*100 + 1.96*ses_3days[1], coefficients_3days[2]*100 + 1.96*ses_3days[2], coefficients_1week[1]*100 + 1.96*ses_1week[1],
coefficients_1week[2]*100 + 1.96*ses_1week[2])
tab0$Ci_lower<- c(coefficients_3days[1]*100 - 1.96*ses_3days[1], coefficients_3days[2]*100 - 1.96*ses_3days[2], coefficients_1week[1]*100 - 1.96*ses_1week[1],
coefficients_1week[2]*100 - 1.96*ses_1week[2])
tab0[1,2]<-"Control"
tab0[2,2]<-"Email"
tab0[3,2]<-"Control"
tab0[4,2]<-"Email"
ggplot(tab0, aes(x=Time, y=Mean, colour=Condition)) +
geom_errorbar(aes(ymin=Ci_lower, ymax=Ci_upper), width=.1) +  scale_colour_manual(values=c("grey40", "black", "grey40", "black")) +
geom_line() + geom_point() + geom_hline(yintercept=0, colour="grey", linetype = "dashed", size = 1) +
theme_bw() + ggtitle("% writing to their MP after 3 and 7 days") + coord_cartesian(ylim = c(0, 4)) +  ylab("% writing to their MP") +  xlab("Days after treatment")
ggsave("results_time.png", width = 6, height = 5)
library(estimatr)
coefficients_1week<-lm(outcome_1week ~ treatdum, data=data1)$coefficients
coefficients_3days<-lm(outcome ~ treatdum, data=data1)$coefficients
ses_1week<-(lm(outcome_1week ~ treatdum, data=data1)$std.error)*100
ses_3days<-(lm(outcome ~ treatdum, data=data1)$std.error)*100
tab0<-NA
tab0 <- data.frame(c(rep("t+3",1), rep("t+3",1), rep("t+7",1), rep("t+7",1)))
tab0$Time <- NA
tab0$Condition <- NA
tab0$mean <- NA
tab0$Cilower <- NA
tab0$Ciupper <- NA
colnames(tab0) <- c("Time", "Condition", "Mean", "Ci_lower", "Ci_upper")
tab0[1,3]<-coefficients_3days[1]*100
tab0[2,3]<-coefficients_3days[2]*100
tab0[3,3]<-coefficients_1week[1]*100
tab0[4,3]<-coefficients_1week[2]*100
tab0$Ci_upper<- c(coefficients_3days[1]*100 + 1.96*ses_3days[1], coefficients_3days[2]*100 + 1.96*ses_3days[2], coefficients_1week[1]*100 + 1.96*ses_1week[1],
coefficients_1week[2]*100 + 1.96*ses_1week[2])
tab0$Ci_lower<- c(coefficients_3days[1]*100 - 1.96*ses_3days[1], coefficients_3days[2]*100 - 1.96*ses_3days[2], coefficients_1week[1]*100 - 1.96*ses_1week[1],
coefficients_1week[2]*100 - 1.96*ses_1week[2])
tab0[1,2]<-"Control"
tab0[2,2]<-"Email"
tab0[3,2]<-"Control"
tab0[4,2]<-"Email"
ggplot(tab0, aes(x=Time, y=Mean, colour=Condition)) +
geom_errorbar(aes(ymin=Ci_lower, ymax=Ci_upper), width=.1) +  scale_colour_manual(values=c("grey40", "black", "grey40", "black")) +
geom_line() + geom_point() + geom_hline(yintercept=0, colour="grey", linetype = "dashed", size = 1) +
theme_bw() + ggtitle("% writing to their MP after 3 and 7 days") + coord_cartesian(ylim = c(0, 4)) +  ylab("% writing to their MP") +  xlab("Days after treatment")
ggsave("results_time.png", width = 6, height = 5)
library(estimatr)
coefficients_1week<-lm_robust(outcome_1week ~ treatdum, data=data1)$coefficients
coefficients_3days<-lm_robust(outcome ~ treatdum, data=data1)$coefficients
ses_1week<-(lm_robust(outcome_1week ~ treatdum, data=data1)$std.error)*100
ses_3days<-(lm_robust(outcome ~ treatdum, data=data1)$std.error)*100
tab0<-NA
tab0 <- data.frame(c(rep("t+3",1), rep("t+3",1), rep("t+7",1), rep("t+7",1)))
tab0$Time <- NA
tab0$Condition <- NA
tab0$mean <- NA
tab0$Cilower <- NA
tab0$Ciupper <- NA
colnames(tab0) <- c("Time", "Condition", "Mean", "Ci_lower", "Ci_upper")
tab0[1,3]<-coefficients_3days[1]*100
tab0[2,3]<-coefficients_3days[2]*100
tab0[3,3]<-coefficients_1week[1]*100
tab0[4,3]<-coefficients_1week[2]*100
tab0$Ci_upper<- c(coefficients_3days[1]*100 + 1.96*ses_3days[1], coefficients_3days[2]*100 + 1.96*ses_3days[2], coefficients_1week[1]*100 + 1.96*ses_1week[1],
coefficients_1week[2]*100 + 1.96*ses_1week[2])
tab0$Ci_lower<- c(coefficients_3days[1]*100 - 1.96*ses_3days[1], coefficients_3days[2]*100 - 1.96*ses_3days[2], coefficients_1week[1]*100 - 1.96*ses_1week[1],
coefficients_1week[2]*100 - 1.96*ses_1week[2])
tab0[1,2]<-"Control"
tab0[2,2]<-"Email"
tab0[3,2]<-"Control"
tab0[4,2]<-"Email"
ggplot(tab0, aes(x=Time, y=Mean, colour=Condition)) +
geom_errorbar(aes(ymin=Ci_lower, ymax=Ci_upper), width=.1) +  scale_colour_manual(values=c("grey40", "black", "grey40", "black")) +
geom_line() + geom_point() + geom_hline(yintercept=0, colour="grey", linetype = "dashed", size = 1) +
theme_bw() + ggtitle("% writing to their MP after 3 and 7 days") + coord_cartesian(ylim = c(0, 4)) +  ylab("% writing to their MP") +  xlab("Days after treatment")
ggsave("results_time.png", width = 6, height = 5)
View(model3)
coefficients_1week<-lm_robust(outcome_1week ~ treatdum, data=data1)$coefficients
coefficients_3days<-lm_robust(outcome ~ treatdum, data=data1)$coefficients
ses_1week<-(lm_robust(outcome_1week ~ treatdum, data=data1)$std.error)*100
ses_3days<-(lm_robust(outcome ~ treatdum, data=data1)$std.error)*100
tab0<-NA
tab0 <- data.frame(c(rep("t+3",1), rep("t+3",1), rep("t+7",1), rep("t+7",1)))
tab0$Time <- NA
tab0$Condition <- NA
tab0$mean <- NA
tab0$Cilower <- NA
tab0$Ciupper <- NA
colnames(tab0) <- c("Time", "Condition", "Mean", "Ci_lower", "Ci_upper")
tab0[1,3]<-coefficients_3days[1]*100
tab0[2,3]<-coefficients_3days[2]*100
tab0[3,3]<-coefficients_1week[1]*100
tab0[4,3]<-coefficients_1week[2]*100
tab0$Ci_upper<- c(coefficients_3days[1]*100 + 1.96*ses_3days[1], coefficients_3days[2]*100 + 1.96*ses_3days[2], coefficients_1week[1]*100 + 1.96*ses_1week[1],
coefficients_1week[2]*100 + 1.96*ses_1week[2])
tab0$Ci_lower<- c(coefficients_3days[1]*100 - 1.96*ses_3days[1], coefficients_3days[2]*100 - 1.96*ses_3days[2], coefficients_1week[1]*100 - 1.96*ses_1week[1],
coefficients_1week[2]*100 - 1.96*ses_1week[2])
tab0[1,2]<-"Control"
tab0[2,2]<-"Email"
tab0[3,2]<-"Control"
tab0[4,2]<-"Email"
ggplot(tab0, aes(x=Time, y=Mean, colour=Condition)) +
geom_errorbar(aes(ymin=Ci_lower, ymax=Ci_upper), width=.1) +  scale_colour_manual(values=c("grey40", "blue2", "grey40", "blue2")) +
geom_line() + geom_point() + geom_hline(yintercept=0, colour="grey", linetype = "dashed", size = 1) +
theme_bw() + ggtitle("% writing to their MP after 3 and 7 days") + coord_cartesian(ylim = c(0, 4)) +  ylab("% writing to their MP") +  xlab("Days after treatment")
ggsave("Figure1.png", dpi=600)
ggplot(tab0, aes(x=Time, y=Mean, colour=Condition)) +
geom_errorbar(aes(ymin=Ci_lower, ymax=Ci_upper), width=.1) +  scale_colour_manual(values=c("grey40", "mediumvioletred", "grey40", "mediumvioletred")) +
geom_line() + geom_point() + geom_hline(yintercept=0, colour="grey", linetype = "dashed", size = 1) +
theme_bw() + ggtitle("% writing to their MP after 3 and 7 days") + coord_cartesian(ylim = c(0, 4)) +  ylab("% writing to their MP") +  xlab("Days after treatment")
ggsave("Figure1.png", dpi=600)
ggplot(tab0, aes(x=Time, y=Mean, colour=Condition)) +
geom_errorbar(aes(ymin=Ci_lower, ymax=Ci_upper), width=.1) +  scale_colour_manual(values=c("grey40", "mediumvioletred", "grey40", "mediumvioletred")) +
geom_line() + geom_point(aes(shape=Condition)) + geom_hline(yintercept=0, colour="grey", linetype = "dashed", size = 1) +
theme_bw() + ggtitle("% writing to their MP after 3 and 7 days") + coord_cartesian(ylim = c(0, 4)) +  ylab("% writing to their MP") +  xlab("Days after treatment")
ggsave("Figure1.png", dpi=600)
ggplot(tab0, aes(x=Time, y=Mean, colour=Condition)) +
geom_errorbar(aes(ymin=Ci_lower, ymax=Ci_upper), width=.2) +  scale_colour_manual(values=c("grey40", "mediumvioletred", "grey40", "mediumvioletred")) +
geom_line() + geom_point(aes(shape=Condition)) + geom_hline(yintercept=0, colour="grey", linetype = "dashed", size = 1) +
theme_bw() + ggtitle("% writing to their MP after 3 and 7 days") + coord_cartesian(ylim = c(0, 4)) +  ylab("% writing to their MP") +  xlab("Days after treatment")
ggsave("Figure1.png", dpi=600)
ggplot(tab0, aes(x=Time, y=Mean, colour=Condition)) +
geom_errorbar(aes(ymin=Ci_lower, ymax=Ci_upper), width=.05) +  scale_colour_manual(values=c("grey40", "mediumvioletred", "grey40", "mediumvioletred")) +
geom_line() + geom_point(aes(shape=Condition)) + geom_hline(yintercept=0, colour="grey", linetype = "dashed", size = 1) +
theme_bw() + ggtitle("% writing to their MP after 3 and 7 days") + coord_cartesian(ylim = c(0, 4)) +  ylab("% writing to their MP") +  xlab("Days after treatment")
ggsave("Figure1.png", dpi=600)
ggplot(tab0, aes(x=Time, y=Mean, colour=Condition)) +
geom_errorbar(aes(ymin=Ci_lower, ymax=Ci_upper), width=.07) +  scale_colour_manual(values=c("grey40", "mediumvioletred", "grey40", "mediumvioletred")) +
geom_line() + geom_point(aes(shape=Condition)) + geom_hline(yintercept=0, colour="grey", linetype = "dashed", size = 1) +
theme_bw() + ggtitle("% writing to their MP after 3 and 7 days") + coord_cartesian(ylim = c(0, 4)) +  ylab("% writing to their MP") +  xlab("Days after treatment")
ggsave("Figure1.png", dpi=600)
data1$donor_num=as.numeric(data1$donor)
data1$isdonor<-NA
data1$isdonor[data1$donor_num==2]<-1
data1$nodonor<-NA
data1$nodonor[data1$donor_num==1]<-1
sub_donor<-subset(data1, !is.na(isdonor))
sub_nodonor<-subset(data1, !is.na(nodonor))
full_coef<-lm_robust(outcome ~ position + urgency, data=data1)$coefficients
full_cilow<-lm_robust(outcome ~ position + urgency, data=data1)$conf.low
full_cihigh<-lm_robust(outcome ~ position + urgency, data=data1)$conf.high
donor_coef<-lm_robust(outcome ~ position + urgency, data=sub_donor)$coefficients
donor_cilow<-lm_robust(outcome ~ position + urgency, data=sub_donor)$conf.low
donor_cihigh<-lm_robust(outcome ~ position + urgency, data=sub_donor)$conf.high
nodonor_coef<-lm_robust(outcome ~ position + urgency, data=sub_nodonor)$coefficients
nodonor_cilow<-lm_robust(outcome ~ position + urgency, data=sub_nodonor)$conf.low
nodonor_cihigh<-lm_robust(outcome ~ position + urgency, data=sub_nodonor)$conf.high
tab3<-NA
tab3 <- data.frame(c(rep("1. Full sample",1), rep("2. Donor",1), rep("3. No donor",1)))
tab3$donor <- NA
tab3$ITT<- NA
tab3$Cilower <- NA
tab3$Ciupper <- NA
colnames(tab3) <- c("Donor", "ITT","Ci_lower", "Ci_upper")
tab3$ITT<- c(full_coef[2], donor_coef[2], nodonor_coef[2])*100
tab3$Ci_upper<- c(full_cihigh[2], donor_cihigh[2], nodonor_cihigh[2])*100
tab3$Ci_lower<- c(full_cilow[2], donor_cilow[2], nodonor_cilow[2])*100
graphdb <- ggplot(tab3,aes(x = Donor, y = ITT,ymin = Ci_lower, ymax = Ci_upper))
graphdb + scale_colour_manual(values=c("black", "black")) + geom_point(position=position_dodge(width=0.8) ,size = 3) +
geom_linerange(position=position_dodge(width=0.5), size =0.5) +
geom_hline(yintercept=0, colour="grey", linetype = "dashed", size = 1) +
theme_bw() + ggtitle("ITT of revealing position on writing to MP") + coord_cartesian(ylim = c(-1.5, 1.5)) +  ylab("ITT in %-points")
ggsave("Figure4.png", dpi=600)
data1$donor_num=as.numeric(data1$donor)
data1$isdonor<-NA
data1$isdonor[data1$donor_num==1]<-1
data1$nodonor<-NA
data1$nodonor[data1$donor_num==0]<-1
sub_donor<-subset(data1, !is.na(isdonor))
sub_nodonor<-subset(data1, !is.na(nodonor))
full_coef<-lm_robust(outcome ~ position + urgency, data=data1)$coefficients
full_cilow<-lm_robust(outcome ~ position + urgency, data=data1)$conf.low
full_cihigh<-lm_robust(outcome ~ position + urgency, data=data1)$conf.high
donor_coef<-lm_robust(outcome ~ position + urgency, data=sub_donor)$coefficients
donor_cilow<-lm_robust(outcome ~ position + urgency, data=sub_donor)$conf.low
donor_cihigh<-lm_robust(outcome ~ position + urgency, data=sub_donor)$conf.high
nodonor_coef<-lm_robust(outcome ~ position + urgency, data=sub_nodonor)$coefficients
nodonor_cilow<-lm_robust(outcome ~ position + urgency, data=sub_nodonor)$conf.low
nodonor_cihigh<-lm_robust(outcome ~ position + urgency, data=sub_nodonor)$conf.high
tab3<-NA
tab3 <- data.frame(c(rep("1. Full sample",1), rep("2. Donor",1), rep("3. No donor",1)))
tab3$donor <- NA
tab3$ITT<- NA
tab3$Cilower <- NA
tab3$Ciupper <- NA
colnames(tab3) <- c("Donor", "ITT","Ci_lower", "Ci_upper")
tab3$ITT<- c(full_coef[2], donor_coef[2], nodonor_coef[2])*100
tab3$Ci_upper<- c(full_cihigh[2], donor_cihigh[2], nodonor_cihigh[2])*100
tab3$Ci_lower<- c(full_cilow[2], donor_cilow[2], nodonor_cilow[2])*100
graphdb <- ggplot(tab3,aes(x = Donor, y = ITT,ymin = Ci_lower, ymax = Ci_upper))
graphdb + scale_colour_manual(values=c("black", "black")) + geom_point(position=position_dodge(width=0.8) ,size = 3) +
geom_linerange(position=position_dodge(width=0.5), size =0.5) +
geom_hline(yintercept=0, colour="grey", linetype = "dashed", size = 1) +
theme_bw() + ggtitle("ITT of revealing position on writing to MP") + coord_cartesian(ylim = c(-1.5, 1.5)) +  ylab("ITT in %-points")
ggsave("Figure4.png", dpi=600)
graphdb <- ggplot(tab3,aes(x = Donor, y = ITT,ymin = Ci_lower, ymax = Ci_upper))
graphdb + scale_colour_manual(values=c("mediumvioletred", "mediumvioletred")) + geom_point(position=position_dodge(width=0.8) ,size = 3) +
geom_linerange(position=position_dodge(width=0.5), size =0.5) +
geom_hline(yintercept=0, colour="grey", linetype = "dashed", size = 1) +
theme_bw() + ggtitle("ITT of revealing position on writing to MP") + coord_cartesian(ylim = c(-1.5, 1.5)) +  ylab("ITT in %-points")
ggsave("Figure4.png", dpi=600)
graphdb <- ggplot(tab3,aes(x = Donor, y = ITT,ymin = Ci_lower, ymax = Ci_upper))
graphdb + scale_colour_manual(values=c("mediumvioletred", "mediumvioletred")) + geom_point(position=position_dodge(width=0.8) ,size = 3) +
geom_linerange(position=position_dodge(width=0.5), size =0.5) +
geom_hline(yintercept=0, colour="grey", linetype = "dashed", size = 1) +
theme_bw() + ggtitle("ITT of revealing position on writing to MP") + coord_cartesian(ylim = c(-1.5, 1.5)) +  ylab("ITT in %-points")
graphdb <- ggplot(tab3,aes(x = Donor, y = ITT,ymin = Ci_lower, ymax = Ci_upper))
graphdb + scale_colour_manual(values=c("mediumvioletred", "mediumvioletred")) + geom_point(position=position_dodge(width=0.8) ,size = 3, color="mediumvioletred") +
geom_linerange(position=position_dodge(width=0.5), size =0.5) +
geom_hline(yintercept=0, colour="grey", linetype = "dashed", size = 1) +
theme_bw() + ggtitle("ITT of revealing position on writing to MP") + coord_cartesian(ylim = c(-1.5, 1.5)) +  ylab("ITT in %-points")
ggsave("Figure4.png", dpi=600)
graphdb <- ggplot(tab3,aes(x = Donor, y = ITT,ymin = Ci_lower, ymax = Ci_upper))
graphdb + scale_colour_manual(values=c("mediumvioletred", "mediumvioletred")) + geom_point(position=position_dodge(width=0.8) ,size = 3, color="mediumvioletred") +
geom_linerange(position=position_dodge(width=0.5), color="mediumvioletred", size =0.5) +
geom_hline(yintercept=0, colour="grey", linetype = "dashed", size = 1) +
theme_bw() + ggtitle("ITT of revealing position on writing to MP") + coord_cartesian(ylim = c(-1.5, 1.5)) +  ylab("ITT in %-points")
ggsave("Figure4.png", dpi=600)
##Figure A8##
coefficients<-lm_robust(outcome_1week ~ treatvar, data=data1)$coefficients
tab1[1,2]<-coefficients[2]*100
tab1[2,2]<-coefficients[3]*100
tab1[3,2]<-coefficients[4]*100
tab1[4,2]<-coefficients[5]*100
conflow<-lm_robust(outcome_1week ~ treatvar, data=data1)$conf.low
confhigh<-lm_robust(outcome_1week ~ treatvar, data=data1)$conf.high
tab1[1,3]<-conflow[2]*100
tab1[2,3]<-conflow[3]*100
tab1[3,3]<-conflow[4]*100
tab1[4,3]<-conflow[5]*100
tab1[1,4]<-confhigh[2]*100
tab1[2,4]<-confhigh[3]*100
tab1[3,4]<-confhigh[4]*100
tab1[4,4]<-confhigh[5]*100
tab1[1,5]<-"Donate"
tab1[2,5]<-"Donate"
tab1[3,5]<-"Donate"
tab1[4,5]<-"Donate"
graphdb <- ggplot(tab1,aes(x = Treatment, y = ITT,ymin = Ci_lower, ymax = Ci_upper))
graphdb + scale_colour_manual(values=c("black", "black", "black", "black")) + geom_point(position=position_dodge(width=0.8) ,size = 3) +
geom_linerange(position=position_dodge(width=0.5), size =0.5) +
geom_hline(yintercept=0, colour="grey", linetype = "dashed", size = 1) +
theme_bw() + ggtitle("ITT of email on writing to MP") + coord_cartesian(ylim = c(0, 4)) +  ylab("ITT in %-points")
ggsave("results_ITT.png")
coefficients<-lm_robust(outcome_1week ~ treatvar, data=data1)$coefficients
tab1[1,2]<-coefficients[2]*100
graphdb <- ggplot(tab4,aes(x = Donor, y = ITT,ymin = Ci_lower, ymax = Ci_upper))
graphdb + scale_colour_manual(values=c("black", "black")) + geom_point(position=position_dodge(width=0.8) ,size = 3) +
geom_linerange(position=position_dodge(width=0.5), size =0.5) +
geom_hline(yintercept=0, colour="grey", linetype = "dashed", size = 1) +
theme_bw() + ggtitle("ITT of urgency cue on writing to MP") + coord_cartesian(ylim = c(-1.5, 1.5)) +  ylab("ITT in %-points")
ggsave("results_donor2.png", width = 6, height = 5)
tab4<-NA
tab4 <- data.frame(c(rep("1. Full sample",1), rep("2. Donor",1), rep("3. No donor",1)))
tab4$donor <- NA
tab4$ITT<- NA
tab4$Cilower <- NA
tab4$Ciupper <- NA
colnames(tab4) <- c("Donor", "ITT","Ci_lower", "Ci_upper")
tab4$ITT<- c(full_coef[3], donor_coef[3], nodonor_coef[3])*100
tab4$Ci_upper<- c(full_cihigh[3], donor_cihigh[3], nodonor_cihigh[3])*100
tab4$Ci_lower<- c(full_cilow[3], donor_cilow[3], nodonor_cilow[3])*100
graphdb <- ggplot(tab4,aes(x = Donor, y = ITT,ymin = Ci_lower, ymax = Ci_upper))
graphdb + scale_colour_manual(values=c("black", "black")) + geom_point(position=position_dodge(width=0.8) ,size = 3) +
geom_linerange(position=position_dodge(width=0.5), size =0.5) +
geom_hline(yintercept=0, colour="grey", linetype = "dashed", size = 1) +
theme_bw() + ggtitle("ITT of urgency cue on writing to MP") + coord_cartesian(ylim = c(-1.5, 1.5)) +  ylab("ITT in %-points")
ggsave("results_donor2.png", width = 6, height = 5)
coefficients<-lm_robust(outcome_1week ~ treatvar, data=data1)$coefficients
tab1<-NA
tab1[1,2]<-coefficients[2]*100
tab1[2,2]<-coefficients[3]*100
tab1[3,2]<-coefficients[4]*100
tab1[4,2]<-coefficients[5]*100
conflow<-lm_robust(outcome_1week ~ treatvar, data=data1)$conf.low
confhigh<-lm_robust(outcome_1week ~ treatvar, data=data1)$conf.high
tab1[1,3]<-conflow[2]*100
tab1[2,3]<-conflow[3]*100
tab1[3,3]<-conflow[4]*100
tab1[4,3]<-conflow[5]*100
tab1[1,4]<-confhigh[2]*100
tab1[2,4]<-confhigh[3]*100
tab1[3,4]<-confhigh[4]*100
tab1[4,4]<-confhigh[5]*100
tab1[1,5]<-"Donate"
tab1[2,5]<-"Donate"
tab1[3,5]<-"Donate"
tab1[4,5]<-"Donate"
graphdb <- ggplot(tab1,aes(x = Treatment, y = ITT,ymin = Ci_lower, ymax = Ci_upper))
graphdb + scale_colour_manual(values=c("black", "black", "black", "black")) + geom_point(position=position_dodge(width=0.8) ,size = 3) +
geom_linerange(position=position_dodge(width=0.5), size =0.5) +
geom_hline(yintercept=0, colour="grey", linetype = "dashed", size = 1) +
theme_bw() + ggtitle("ITT of email on writing to MP") + coord_cartesian(ylim = c(0, 4)) +  ylab("ITT in %-points")
ggsave("FigureA8.png")
coefficients<-lm_robust(outcome_1week ~ treatvar, data=data1)$coefficients
tab1<-NA
tab1[1,2]<-coefficients[1]*100
tab1[2,2]<-coefficients[2]*100
tab1[3,2]<-coefficients[3]*100
tab1[4,2]<-coefficients[4]*100
coefficients<-lm_robust(outcome_1week ~ treatvar, data=data1)$coefficients
coefficients<-lm_robust(outcome_1week ~ treatvar, data=data1)$coefficients
tab1[1,2]<-coefficients[2]*100
tab1[2,2]<-coefficients[3]*100
tab1[3,2]<-coefficients[4]*100
tab1[4,2]<-coefficients[5]*100
coefficients<-lm_robust(outcome_1week ~ treatvar, data=data1)$coefficients
tab1[2,2]<-coefficients[2]*100
essdata<-read.dta("ESS_9waves.dta")
essdata$contact<-NA
essdata$contact[essdata$contplt==1]<-1
essdata$contact[essdata$contplt==2]<-0
essdata$GB<-NA
essdata$GB[essdata$cntry=="GB"]<-1
GBdata<-subset(essdata, !is.na(GB))
tab1<-crosstab(GBdata$year, GBdata$contact, weight = GBdata$dweight, total.r=FALSE, total.c=FALSE, prop.r = TRUE, )
xtable(tab1)
library(xtable)
essdata<-read.dta("ESS_9wavesold.dta")
essdata$contact<-NA
essdata$contact[essdata$contplt==1]<-1
essdata$contact[essdata$contplt==2]<-0
essdata$GB<-NA
essdata$GB[essdata$cntry=="GB"]<-1
GBdata<-subset(essdata, !is.na(GB))
tab1<-crosstab(GBdata$year, GBdata$contact, weight = GBdata$dweight, total.r=FALSE, total.c=FALSE, prop.r = TRUE, )
xtable(tab1)
library(matrixStats)
library(descr)
essdata<-read.dta("ESS_9waves.dta")
essdata$contact<-NA
essdata$contact[essdata$contplt==1]<-1
essdata$contact[essdata$contplt==2]<-0
essdata$GB<-NA
essdata$GB[essdata$cntry=="GB"]<-1
GBdata<-subset(essdata, !is.na(GB))
tab1<-crosstab(GBdata$year, GBdata$contact, weight = GBdata$dweight, total.r=FALSE, total.c=FALSE, prop.r = TRUE, )
xtable(tab1)
essdata<-read.dta("ESS_9waves.dta")
essdata$contact<-NA
essdata$contact[essdata$contplt==1]<-1
essdata$contact[essdata$contplt==2]<-0
library(readstata13)
essdata<-read.dta("ESS_9waves.dta")
essdata$contact<-NA
essdata$contact[essdata$contplt==1]<-1
essdata$contact[essdata$contplt==2]<-0
essdata$GB<-NA
essdata$GB[essdata$cntry=="GB"]<-1
GBdata<-subset(essdata, !is.na(GB))
tab1<-crosstab(GBdata$year, GBdata$contact, weight = GBdata$dweight, total.r=FALSE, total.c=FALSE, prop.r = TRUE, )
xtable(tab1)
essdata<-read.dta("ESS_9waves.dta")
library(readstata13)
essdata<-read.dta("ESS_9waves.dta")
